#include <iostream>
#include <string>
using namespace std;

int main() {
    string s;
    getline(cin, s);
    int count[26] = {0};
    for (char c : s) {
        count[c - 'a']++;
    }
    int maxCount = 0;
    char maxChar = 'z';
    for (int i = 0; i < 26; i++) {
        if (count[i] > maxCount) {
            maxCount = count[i];
            maxChar = 'a' + i;
        } else if (count[i] == maxCount) {
            maxChar = min(maxChar, static_cast<char>('a' + i));
        }
    }
    cout << maxChar << " " << maxCount << endl;
    return 0;
}
